package org.eventexample.ws;

import org.eventexample.www.events.Event;
import org.eventexample.www.events.EventsArray;
import org.eventexample.www.events.GetAllEvents;
import org.eventexample.www.events.GetAllEventsResponse;
import org.eventexample.www.events.GetEventsByDate;
import org.eventexample.www.events.GetEventsByDateResponse;
import org.eventexample.www.events.GetEventsByKeyword;
import org.eventexample.www.events.GetEventsByKeywordResponse;


public class EventBusiness implements EventsSkeletonInterface
{

	@Override
	public GetEventsByKeywordResponse getEventsByKeyword(GetEventsByKeyword getEventsByKeyword) throws GetEventsByKeywordFaultException {
		GetEventsByKeywordResponse object = new GetEventsByKeywordResponse();
		
		String keyword = (String)getEventsByKeyword.getKeyword();
		
		EventsDAO dao = new EventsDAO();
		Event[] eventsResult = dao.getEventsByKeyword(keyword);
		
		EventsArray array = new EventsArray();
		array.setEvent(eventsResult);
		object.setOut(array);
		
		return object;
	}

	@Override
	public GetEventsByDateResponse getEventsByDate(GetEventsByDate getEventsByDate) throws GetEventsByDateFaultException {
		GetEventsByDateResponse object = new GetEventsByDateResponse();
		
		String startDate = (String)getEventsByDate.getStart();
		String endDate = (String)getEventsByDate.getEnd();
		
		EventsDAO dao = new EventsDAO();
		Event[] eventsResult = dao.getEventsByDate(startDate, endDate);
		
		EventsArray array = new EventsArray();
		array.setEvent(eventsResult);
		object.setOut(array);
		
		return object;
	}

	@Override
	public GetAllEventsResponse getAllEvents(GetAllEvents getAllEvents) throws GetAllEventsFaultException {
		
		GetAllEventsResponse object = new GetAllEventsResponse();
		
		EventsDAO dao = new EventsDAO();
		Event[] eventsResult = dao.getAllEvents();
		
		EventsArray array = new EventsArray();
		array.setEvent(eventsResult);
		object.setOut(array);
		
		return object;
	}


}
